package com.scwatch.ext.domain;

import com.scwatch.core.domain.Site;
import com.scwatch.core.domain.User;
import com.scwatch.core.support.Siteable;

import javax.persistence.*;
import java.util.Date;

/**
 * 
* @Description: 计划任务信息
* @author dxm
* @date 2017年9月18日19:52:26
 */
@Entity
@Table(name = "task_schedule_job")
public class ScheduleJob implements Siteable, java.io.Serializable{
	private static final long serialVersionUID = 1L;

	public static final String STATUS_RUNNING = "1";
	public static final String STATUS_NOT_RUNNING = "0";
	public static final String CONCURRENT_IS = "1";
	public static final String CONCURRENT_NOT = "0";


	private Integer id;
	private Site site;
	private User user;
	private Date createTime;
	private Date updateTime;
	/**
	 * 任务名称
	 */

	private String jobName;
	/**
	 * 任务分组
	 */

	private String jobGroup;
	/**
	 * 任务状态 是否启动任务
	 */

	private String jobStatus;
	/**
	 * cron表达式
	 */

	private String cronExpression;
	/**
	 * 描述
	 */

	private String description;
	/**
	 * 任务执行时调用哪个类的方法 包名+类名
	 */

	private String beanClass;
	/**
	 * 任务是否有状态
	 */

	private String isConcurrent;
	/**
	 * spring bean
	 */

	private String springId;
	/**
	 * 任务调用的方法名
	 */

	private String methodName;

	/**
	 * 执行状态 0、启动运行 1、恢复 2、暂停
	 **/
	private Integer isRestore;

	/**
	 * 参数设置 数组
	 **/
	private String parSet;

	@Column(name = "par_set", nullable = false)
	public String getParSet() {
		return parSet;
	}

	public void setParSet(String parSet) {
		this.parSet = parSet;
	}

	@Column(name = "is_restore", nullable = false)
	public Integer getIsRestore() {
		return isRestore;
	}

	public void setIsRestore(Integer isRestore) {
		this.isRestore = isRestore;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "site_id", nullable = false)
	public Site getSite() {
		return site;
	}

	public void setSite(Site site) {
		this.site = site;
	}


	@Id
	@Column(name = "job_id", unique = true, nullable = false)
	@TableGenerator(name = "tg_task_schedule_job", pkColumnValue = "task_schedule_job", initialValue = 1, allocationSize = 10)
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_task_schedule_job")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "job_name", nullable = false)
	public String getJobName() {
		return jobName;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	@Column(name = "job_group", nullable = false)
	public String getJobGroup() {
		return jobGroup;
	}

	public void setJobGroup(String jobGroup) {
		this.jobGroup = jobGroup;
	}

	@Column(name = "job_status", nullable = false)
	public String getJobStatus() {
		return jobStatus;
	}

	public void setJobStatus(String jobStatus) {
		this.jobStatus = jobStatus;
	}

	@Column(name = "cron_expression", nullable = false)
	public String getCronExpression() {
		return cronExpression;
	}

	public void setCronExpression(String cronExpression) {
		this.cronExpression = cronExpression;
	}

	@Column(name = "description", nullable = false)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "bean_class", nullable = false)
	public String getBeanClass() {
		return beanClass;
	}

	public void setBeanClass(String beanClass) {
		this.beanClass = beanClass;
	}

	@Column(name = "is_concurrent", nullable = false)
	public String getIsConcurrent() {
		return isConcurrent;
	}

	public void setIsConcurrent(String isConcurrent) {
		this.isConcurrent = isConcurrent;
	}

	@Column(name = "spring_id", nullable = false)
	public String getSpringId() {
		return springId;
	}

	public void setSpringId(String springId) {
		this.springId = springId;
	}

	@Column(name = "method_name", nullable = false)
	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}
}